﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 3.5
// Code is generated on: Monday, December 17, 2012 11:21:26 AM
// Code is generated using templates: SD.TemplateBindings.SharedTemplates.NET20
// Templates vendor: Solutions Design.
// Templates version: 
//////////////////////////////////////////////////////////////
using System;
using System.Collections;
using System.Collections.Generic;
using WHMS;
using WHMS.FactoryClasses;
using WHMS.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace WHMS.RelationClasses
{
	/// <summary>Implements the relations factory for the entity: User. </summary>
	public partial class UserRelations
	{
		/// <summary>CTor</summary>
		public UserRelations()
		{
		}

		/// <summary>Gets all relations of the UserEntity as a list of IEntityRelation objects.</summary>
		/// <returns>a list of IEntityRelation objects</returns>
		public virtual List<IEntityRelation> GetAllRelations()
		{
			List<IEntityRelation> toReturn = new List<IEntityRelation>();
			toReturn.Add(this.ProjectEntityUsingManagerId);
			toReturn.Add(this.StorekeeperEntityUsingKeeperId);
			toReturn.Add(this.SupplyOrderEntityUsingCreatedBy);
			toReturn.Add(this.TransferRequestEntityUsingCreatedBy);
			toReturn.Add(this.UserRoleEntityUsingUserId);
			toReturn.Add(this.WithdrawRequestEntityUsingAccountantId);
			toReturn.Add(this.WithdrawRequestEntityUsingCreatedBy);
			toReturn.Add(this.WithdrawTransactionEntityUsingAccountantId);
			return toReturn;
		}

		#region Class Property Declarations

		/// <summary>Returns a new IEntityRelation object, between UserEntity and ProjectEntity over the 1:n relation they have, using the relation between the fields:
		/// User.Id - Project.ManagerId
		/// </summary>
		public virtual IEntityRelation ProjectEntityUsingManagerId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "Projects" , true);
				relation.AddEntityFieldPair(UserFields.Id, ProjectFields.ManagerId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UserEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ProjectEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between UserEntity and StorekeeperEntity over the 1:n relation they have, using the relation between the fields:
		/// User.Id - Storekeeper.KeeperId
		/// </summary>
		public virtual IEntityRelation StorekeeperEntityUsingKeeperId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "Storekeepers" , true);
				relation.AddEntityFieldPair(UserFields.Id, StorekeeperFields.KeeperId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UserEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("StorekeeperEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between UserEntity and SupplyOrderEntity over the 1:n relation they have, using the relation between the fields:
		/// User.Id - SupplyOrder.CreatedBy
		/// </summary>
		public virtual IEntityRelation SupplyOrderEntityUsingCreatedBy
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "SupplyOrders" , true);
				relation.AddEntityFieldPair(UserFields.Id, SupplyOrderFields.CreatedBy);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UserEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("SupplyOrderEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between UserEntity and TransferRequestEntity over the 1:n relation they have, using the relation between the fields:
		/// User.Id - TransferRequest.CreatedBy
		/// </summary>
		public virtual IEntityRelation TransferRequestEntityUsingCreatedBy
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "TransferRequests" , true);
				relation.AddEntityFieldPair(UserFields.Id, TransferRequestFields.CreatedBy);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UserEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("TransferRequestEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between UserEntity and UserRoleEntity over the 1:n relation they have, using the relation between the fields:
		/// User.Id - UserRole.UserId
		/// </summary>
		public virtual IEntityRelation UserRoleEntityUsingUserId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "UserRoles" , true);
				relation.AddEntityFieldPair(UserFields.Id, UserRoleFields.UserId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UserEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UserRoleEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between UserEntity and WithdrawRequestEntity over the 1:n relation they have, using the relation between the fields:
		/// User.Id - WithdrawRequest.AccountantId
		/// </summary>
		public virtual IEntityRelation WithdrawRequestEntityUsingAccountantId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "WithdrawRequests" , true);
				relation.AddEntityFieldPair(UserFields.Id, WithdrawRequestFields.AccountantId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UserEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WithdrawRequestEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between UserEntity and WithdrawRequestEntity over the 1:n relation they have, using the relation between the fields:
		/// User.Id - WithdrawRequest.CreatedBy
		/// </summary>
		public virtual IEntityRelation WithdrawRequestEntityUsingCreatedBy
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "WithdrawRequests_" , true);
				relation.AddEntityFieldPair(UserFields.Id, WithdrawRequestFields.CreatedBy);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UserEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WithdrawRequestEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between UserEntity and WithdrawTransactionEntity over the 1:n relation they have, using the relation between the fields:
		/// User.Id - WithdrawTransaction.AccountantId
		/// </summary>
		public virtual IEntityRelation WithdrawTransactionEntityUsingAccountantId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "WithdrawTransactions" , true);
				relation.AddEntityFieldPair(UserFields.Id, WithdrawTransactionFields.AccountantId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UserEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WithdrawTransactionEntity", false);
				return relation;
			}
		}


		/// <summary>stub, not used in this entity, only for TargetPerEntity entities.</summary>
		public virtual IEntityRelation GetSubTypeRelation(string subTypeEntityName) { return null; }
		/// <summary>stub, not used in this entity, only for TargetPerEntity entities.</summary>
		public virtual IEntityRelation GetSuperTypeRelation() { return null;}
		#endregion

		#region Included Code

		#endregion
	}
	
	/// <summary>Static class which is used for providing relationship instances which are re-used internally for syncing</summary>
	internal static class StaticUserRelations
	{
		internal static readonly IEntityRelation ProjectEntityUsingManagerIdStatic = new UserRelations().ProjectEntityUsingManagerId;
		internal static readonly IEntityRelation StorekeeperEntityUsingKeeperIdStatic = new UserRelations().StorekeeperEntityUsingKeeperId;
		internal static readonly IEntityRelation SupplyOrderEntityUsingCreatedByStatic = new UserRelations().SupplyOrderEntityUsingCreatedBy;
		internal static readonly IEntityRelation TransferRequestEntityUsingCreatedByStatic = new UserRelations().TransferRequestEntityUsingCreatedBy;
		internal static readonly IEntityRelation UserRoleEntityUsingUserIdStatic = new UserRelations().UserRoleEntityUsingUserId;
		internal static readonly IEntityRelation WithdrawRequestEntityUsingAccountantIdStatic = new UserRelations().WithdrawRequestEntityUsingAccountantId;
		internal static readonly IEntityRelation WithdrawRequestEntityUsingCreatedByStatic = new UserRelations().WithdrawRequestEntityUsingCreatedBy;
		internal static readonly IEntityRelation WithdrawTransactionEntityUsingAccountantIdStatic = new UserRelations().WithdrawTransactionEntityUsingAccountantId;

		/// <summary>CTor</summary>
		static StaticUserRelations()
		{
		}
	}
}
